import instance from "./requery";


// 添加房屋列表接口
const addhourselist = (data) => {
    return instance({
        method: 'POST',
        url: '/user/houses',
        data
    });
}

// 用户登录接口
const userLogin = (data) => {
    return instance.post('/user/login', data);
}

// 搜索关键词
const getKeywords = (cityId, params) => {
  return instance.get(`/area/community?id=${cityId}`, { params });
}



const uploadHouseImage = (data) => {
  return instance({
    method: 'POST',
    url: '/houses/image',
    data,
    headers: {
      // 对于FormData，需要明确设置为multipart/form-data或者让axios自动设置
      'Content-Type': 'multipart/form-data'
    },
    timeout: 15000 // 单独为图片上传设置更长的超时时间
  }).then(response => {
    console.log('图片上传API响应:', response);
    return response;
  }).catch(error => {
    console.error('图片上传API错误:', error);
    throw error;
  });
}

export { addhourselist, userLogin, getKeywords, uploadHouseImage };
